from django.db import models


class CustomerReply(models.Model):
    id = models.AutoField(primary_key=True)
    # 关键字
    keyword = models.CharField(max_length=255)
    # 回复内容
    reply = models.TextField(null=True)

    def to_dict(self):
        res = {
            "id": self.id,
            "keyword": self.keyword,
            "reply": self.reply
        }
        return res

    @staticmethod
    def get_fields():
        return [
            {"field": "id", "remark": "ID"},
            {"field": "keyword", "remark": "问题", "is_query": "1"},
            {"field": "reply", "remark": "回复内容"}
        ]

    class Meta:
        db_table = "customer_reply"
        app_label = "models"
